/**
 * tzdesk系统平台
 * moonvip_admin
 * com.tz.service.role
 * IRoleService.java
 * 创建人:小胡 
 * 时间：2016年11月26日 14:39:13
 *
 */
package com.tz.service.role.impl;

import com.tz.bean.Role;
import com.tz.bean.TzParams;
import com.tz.dao.role.IRoleMapper;
import com.tz.service.role.IRoleService;
import com.tz.util.TmStringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * 角色管理serviceImpl
 * IRoleService
 * 创建人:小胡 
 * 时间：2016年11月26日 14:39:13
 * @version 1.0.0
 * 
 */
@Service
public class RoleServiceImpl implements IRoleService{

	@Autowired
	private IRoleMapper roleMapper;

	@Override
	public List<Role> findRoles(TzParams params){
		if(TmStringUtils.isEmpty(params.getOrder()))params.setOrder("create_time desc");
		return roleMapper.findRoles(params);
	}

	@Override
	public int count(TzParams params){
		return roleMapper.count(params);
	}

	@Override
	public Role get(Integer id) {
		return roleMapper.get(id);
	}

	@Override
	public int save(Role role) {
		return roleMapper.save(role);
	}

	@Override
	public int update(Role role) {
		return roleMapper.update(role);
	}

	@Override
	public int delete(TzParams params) {
		return roleMapper.delete(params);
	}

	@Override
	public int saveRoleUser(@Param("userId") Integer userId, @Param("roleId") Integer roleId) {
		return roleMapper.saveRoleUser(userId, roleId);
	}

	@Override
	public int saveRolePermission(@Param("roleId") Integer roleId, @Param("permissionId") Integer permissionId) {
		return roleMapper.saveRolePermission(roleId, permissionId);
	}

	@Override
	public int deleteRolePermission(@Param("roleId") Integer roleId) {
		return roleMapper.deleteRolePermission(roleId);
	}

	@Override
	public List<HashMap<String ,Object>> findFilterUsers(TzParams params) {
		return roleMapper.findFilterUsers(params);
	}

	@Override
	public int countFilterUsers(TzParams params) {
		return roleMapper.countFilterUsers(params);
	}

	@Override
	public Integer[] findPermissionByRoleId(@Param("roleId") Integer roleId) {
		return roleMapper.findPermissionByRoleId(roleId);
	}

	@Override
	public  HashMap<String,Object>  findRolesByUserId(@Param("userId") Integer userId) {
		return roleMapper.findRolesByUserId(userId);
	}
}
